

 local coefficientofinterest `"  "libdem_extra_vdem"   "l1_gov_change"  "l1_civ_war_all_PRIO"  "l1_int_war_all_PRIO"	 "P_ind_total_f_realshare"   "S_g5_unw_alliance_abs"   "cr_market_accessXIRinv"    "' 

 
foreach x of local  coefficientofinterest {
 
 
clear


use "Temp/Master.dta"

*** rescale libdem measure (in annual data not rescaled to pp yet)
replace libdem_extra_vdem=libdem_extra_vdem*100


 
 forvalues r=1/7{
	 gen  mb_ub_SPEC`r'=.
	 gen mb_p_SPEC`r'=.	
	 gen mb_lb_SPEC`r'=.

}


gen dtax_non_trade_real=d.tax_non_trade_real

gen l1_gov_change= l1.gov_change

gen l1_civ_war_all_PRIO=l1.civ_war_all_PRIO

gen l1_int_war_all_PRIO=l1.int_war_all_PRIO

gen l1_drought_affected_merged= l1.drought_affected_merged


eststo m1_`x': reghdfe dtax_non_trade_real      libdem_extra_vdem   l1_gov_change     , absorb(year iso_n) cluster(  iso_n)  level(90) // Canonical  variables only

 capture replace mb_ub_SPEC1= _b[`x']  + _se[`x']*invttail(e(df_r), 0.05)    
 capture replace mb_p_SPEC1= _b[`x']  										 
 capture replace mb_lb_SPEC1=_b[`x']  - _se[`x']*invttail(e(df_r), 0.05) 	   
 
eststo m2_`x': reghdfe dtax_non_trade_real      libdem_extra_vdem    l1_gov_change  l1_civ_war_all_PRIO  l1_int_war_all_PRIO, absorb(year iso_n) cluster(  iso_n) // civil &  international conflict

 capture replace mb_ub_SPEC2= _b[`x']  + _se[`x']*invttail(e(df_r), 0.05)    
 capture replace mb_p_SPEC2= _b[`x']  										 
 capture replace mb_lb_SPEC2=_b[`x']  - _se[`x']*invttail(e(df_r), 0.05) 	   
  
eststo m3_`x': reghdfe dtax_non_trade_real      libdem_extra_vdem  l1_gov_change l1_civ_war_all_PRIO  l1_int_war_all_PRIO   P_ind_total_f_realshare  , absorb(year iso_n) cluster(  iso_n)  // resources

 capture replace mb_ub_SPEC3= _b[`x']  + _se[`x']*invttail(e(df_r), 0.05)    
 capture replace mb_p_SPEC3= _b[`x']  										 
 capture replace mb_lb_SPEC3=_b[`x']  - _se[`x']*invttail(e(df_r), 0.05) 	   
 
eststo m4_`x': reghdfe dtax_non_trade_real      libdem_extra_vdem    l1_gov_change  l1_civ_war_all_PRIO  l1_int_war_all_PRIO S_g5_unw_alliance_abs  , absorb(year iso_n) cluster(  iso_n) // aid

 capture replace mb_ub_SPEC4= _b[`x']  + _se[`x']*invttail(e(df_r), 0.05)    
 capture replace mb_p_SPEC4= _b[`x']  										 
 capture replace mb_lb_SPEC4=_b[`x']  - _se[`x']*invttail(e(df_r), 0.05) 	   
 
eststo m5_`x': reghdfe dtax_non_trade_real       libdem_extra_vdem   l1_gov_change  l1_civ_war_all_PRIO  l1_int_war_all_PRIO   cr_market_accessXIRinv  , absorb(year iso_n) cluster(  iso_n) // capital markets

 capture replace mb_ub_SPEC5= _b[`x']  + _se[`x']*invttail(e(df_r), 0.05)    
 capture replace mb_p_SPEC5= _b[`x']  										 
 capture replace mb_lb_SPEC5=_b[`x']  - _se[`x']*invttail(e(df_r), 0.05) 	   

eststo m6_`x': reghdfe dtax_non_trade_real       libdem_extra_vdem   l1_gov_change  l1_civ_war_all_PRIO  l1_int_war_all_PRIO	 P_ind_total_f_realshare   S_g5_unw_alliance_abs   cr_market_accessXIRinv    , absorb(year iso_n) cluster(  iso_n) // full specification

 capture replace mb_ub_SPEC6= _b[`x']  + _se[`x']*invttail(e(df_r), 0.05)    
 capture replace mb_p_SPEC6= _b[`x']  										 
 capture replace mb_lb_SPEC6=_b[`x']  - _se[`x']*invttail(e(df_r), 0.05) 	   

eststo m7_`x': reghdfe dtax_non_trade_real       libdem_extra_vdem    l1_gov_change l1_civ_war_all_PRIO  l1_int_war_all_PRIO	 P_ind_total_f_realshare  S_g5_unw_alliance_abs   cr_market_accessXIRinv  l1_drought_affected_merged  g_gdp_yoy inflation_ep l5default_RR social secession indep , absorb(year iso_n) cluster(  iso_n)  // full specification, controls

 capture replace mb_ub_SPEC7= _b[`x']  + _se[`x']*invttail(e(df_r), 0.05)    
 capture replace mb_p_SPEC7= _b[`x']  										 
 capture replace mb_lb_SPEC7=_b[`x']  - _se[`x']*invttail(e(df_r), 0.05) 	   
 
 
 
 
 keep mb_*
  keep if _n==1
 
 gen variable="`x'"
 
 
save "TEMP/res_annual_`x'"    ,replace

  
 
 }
 
 


clear all
 
  
foreach x of local  coefficientofinterest {

append using "TEMP/res_annual_`x'"


}

 


 

  
 
 

 forvalues z=1/7{
		gen e_point_SPEC`z'=  .
		gen e_lb_SPEC`z'=.
		gen e_ub_SPEC`z'=. 
}


 forvalues z=1/7{

	foreach y of local  coefficientofinterest {
			replace e_point_SPEC`z'	= mb_p_SPEC`z'   	if variable=="`y'"
			replace e_lb_SPEC`z'	= mb_lb_SPEC`z'		if variable=="`y'"
			replace e_ub_SPEC`z'	= mb_ub_SPEC`z' 	if variable=="`y'"
		}
		
		
}


***** 
 
 
 keep e_*   variable

 reshape long e_point_SPEC  e_lb_SPEC  e_ub_SPEC , i(   variable) j(SPEC)  string
	 
 destring SPEC, replace
 
 rename  e_point_SPEC 	y 
 rename  e_lb 			yl  
 rename  e_ub  			yu 
 
 *** multiply by 5 to make estimates comparable
 
 foreach x in y yl yu{
 
	replace  `x'=`x'*5
	
	}
 
*****


gen frequency="Annual"  
save "TEMP/res_annual_panel", replace 




**** Append benchmark estimates
	append using "TEMP/benchmark_plot_5years"
	
	
 	
	gen frequency_n=1 		if frequency=="Window_5years"
	replace  frequency_n=2 	if  frequency=="Annual"
 
 
 
 
 
 

separate y, by(frequency_n)
separate yu	, by(frequency_n)
separate yl	, by(frequency_n)
 
 
    
 ** democracy coefficient
 
 
   preserve 

				keep if variable=="libdem_extra_vdem"
				
				* do not show w/o controls
				
					replace SPEC=. if SPEC==6
					replace SPEC=6 if SPEC==7

				gen graph_position=SPEC*10+frequency_n



				label  define x     11  "Five-year benchmark"  12 "Annual estimate"     	///
									21  "Five-year benchmark"  22 "Annual estimate"   		///
									31  "Five-year benchmark"  32 "Annual estimate"  		///
									41  "Five-year benchmark"  42 "Annual estimate"  		///
									51  "Five-year benchmark"  52 "Annual estimate" 		///
									61  "Five-year benchmark"  62 "Annual estimate"  		///
									71  "Five-year benchmark"  72 "Annual estimate"  
									
							 
							 
				label  value  graph_position x 

				 rename graph_position x
							 
				
				
				twoway (scatter y1 x , msymbol(Sh) msize(medium)  xsize(8)) ///
					   (rcap yu1 yl1 x)  ///
					   (scatter y2 x , msymbol(Oh) msize(large)) ///
					   (rcap yu2 yl2 x ), scheme(lean1) ///
					   xlabel(11 "Canonical " 21 "Canonical incl. wars  " 31 "Resources" 41 "Aid" 51 "Credit access" 61 "Full"  , angle(45)) xtitle("Specification")   ///
					   ytitle(Coefficient) yline(0, lpattern(dash)) ///
					   legend( order( 1 "Five-year benchmark" 3 "Annual estimate (times 5)")  position(3) row(6) ring(100) title("Legend", size(medsmall)))  ///
					   title("Coefficient on liberal democracy score ")
					   
					   
					   
					graph save  "Temp/Coefficient_libdem_extra_vdem" , replace 
					graph export  "Output/Graphs/Appendix/APP_FIG_5_1a.pdf" , replace 

	restore 
	 
	  
	
  ** Turnover
  
  
	preserve
	
					keep if variable=="l1_gov_change"
				
					* do not show w/o controls
				
						replace SPEC=. if SPEC==6
						replace SPEC=6 if SPEC==7



					gen graph_position=SPEC*10+frequency_n



				label  define x     12  "Five-year benchmark"  11 "Annual estimate"     	///
									22  "Five-year benchmark"  21 "Annual estimate"   		///
									32  "Five-year benchmark"  31 "Annual estimate"  		///
									42  "Five-year benchmark"  41 "Annual estimate"  		///
									52  "Five-year benchmark"  51 "Annual estimate" 		///
									62  "Five-year benchmark"  61 "Annual estimate"  		///
									72  "Five-year benchmark"  71 "Annual estimate"  
									
							 
							 
				label  value  graph_position x 

				 rename graph_position x
							 
				
				
				twoway (scatter y1 x , msymbol(Sh) msize(medium)  xsize(8)) ///
					   (rcap yu1 yl1 x)  ///
					   (scatter y2 x , msymbol(Oh) msize(large)) ///
					   (rcap yu2 yl2 x ), scheme(lean1) ///
					   xlabel(11 "Canonical " 21 "Canonical incl. wars  " 31 "Resources" 41 "Aid" 51 "Credit access" 61 "Full"  , angle(45)) xtitle("Specification")   ///
					   ytitle(Coefficient) yline(0, lpattern(dash)) ///
					   legend( order(1 "Five-year benchmark" 3 "Annual estimate (times 5)")  position(3) row(6) ring(100) title("Legend", size(medsmall)))  ///
					   title("Coefficient on government turnover")
						   
						   
						   
							graph save "Temp/Coefficient_l1_gov_change" , replace 
							graph export  "Output/Graphs/Appendix/APP_FIG_5_1b.pdf" , replace 
	restore 
			 
  


  	
  ** Civil war
  
  
	preserve
	
					keep if variable=="l1_civ_war_all_PRIO"

					* do not show w/o controls
				
						replace SPEC=. if SPEC==6
						replace SPEC=6 if SPEC==7


					gen graph_position=SPEC*10+frequency_n



				label  define x     12  "Five-year benchmark"  11 "Annual estimate"     	///
									22  "Five-year benchmark"  21 "Annual estimate"   		///
									32  "Five-year benchmark"  31 "Annual estimate"  		///
									42  "Five-year benchmark"  41 "Annual estimate"  		///
									52  "Five-year benchmark"  51 "Annual estimate" 		///
									62  "Five-year benchmark"  61 "Annual estimate"  		 
							 
							 
				label  value  graph_position x 

				 rename graph_position x
							 
				
				
				twoway (scatter y1 x , msymbol(Sh) msize(medium)  xsize(8)) ///
					   (rcap yu1 yl1 x)  ///
					   (scatter y2 x , msymbol(Oh) msize(large)) ///
					   (rcap yu2 yl2 x ), scheme(lean1) ///
					   xlabel(11 "Canonical " 21 "Canonical incl. wars  " 31 "Resources" 41 "Aid" 51 "Credit access" 61 "Full"  , angle(45)) xtitle("Specification")   ///
					   ytitle(Coefficient) yline(0, lpattern(dash)) ///
					   legend( order(1 "Five-year benchmark" 3 "Annual estimate (times 5)")  position(3) row(6) ring(100) title("Legend", size(medsmall)))  ///
 						   title("Coefficient on civil war")
						   
						   
						   
						   graph save "Temp/Coefficient_l1_civ_war_all_PRIO" , replace 
						   graph export  "Output/Graphs/Appendix/APP_FIG_5_1c.pdf" , replace 

	restore 
		
** International vars
  
  
	preserve
	
					keep if variable=="l1_int_war_all_PRIO"

					* do not show w/o controls
				
						replace SPEC=. if SPEC==6
						replace SPEC=6 if SPEC==7


					 gen graph_position=SPEC*10+frequency_n



				label  define x     12  "Five-year benchmark"  11 "Annual estimate"     	///
									22  "Five-year benchmark"  21 "Annual estimate"   		///
									32  "Five-year benchmark"  31 "Annual estimate"  		///
									42  "Five-year benchmark"  41 "Annual estimate"  		///
									52  "Five-year benchmark"  51 "Annual estimate" 		///
									62  "Five-year benchmark"  61 "Annual estimate"  		///
									72  "Five-year benchmark"  71 "Annual estimate"  
									
							 
							 
				label  value  graph_position x 

				 rename graph_position x
							 
				
				
				twoway (scatter y1 x , msymbol(Sh) msize(medium)  xsize(8)) ///
					   (rcap yu1 yl1 x)  ///
					   (scatter y2 x , msymbol(Oh) msize(large)) ///
					   (rcap yu2 yl2 x ), scheme(lean1) ///
					   xlabel(11 "Canonical " 21 "Canonical incl. wars  " 31 "Resources" 41 "Aid" 51 "Credit access" 61 "Full"  , angle(45)) xtitle("Specification")   ///
					   ytitle(Coefficient) yline(0, lpattern(dash)) ///
					   legend( order(1 "Five-year benchmark" 3 "Annual estimate (times 5)")  position(3) row(6) ring(100) title("Legend", size(medsmall)))  ///
						   title("Coefficient on international wars")
						   
						   
						   
						   graph save "Temp/Coefficient_l1_int_war_all_PRIO" , replace 
						   graph export  "Output/Graphs/Appendix/APP_FIG_5_1d.pdf" , replace 
						   
	restore 
			 
** Resources 
  
  
	preserve
	
					keep if variable=="P_ind_total_f_realshare"

					* do not show w/o controls
				
						replace SPEC=. if SPEC==6
						replace SPEC=6 if SPEC==7

					gen graph_position=SPEC*10+frequency_n



				label  define x     12  "Five-year benchmark"  11 "Annual estimate"     	///
									22  "Five-year benchmark"  21 "Annual estimate"   		///
									32  "Five-year benchmark"  31 "Annual estimate"  		///
									42  "Five-year benchmark"  41 "Annual estimate"  		///
									52  "Five-year benchmark"  51 "Annual estimate" 		///
									62  "Five-year benchmark"  61 "Annual estimate"  		 
									
							 
							 
				label  value  graph_position x 

				 rename graph_position x
							 
				
				
				twoway (scatter y1 x , msymbol(Sh) msize(medium)  xsize(8)) ///
					   (rcap yu1 yl1 x)  ///
					   (scatter y2 x , msymbol(Oh) msize(large)) ///
					   (rcap yu2 yl2 x ), scheme(lean1) ///
					   xlabel(11 "Canonical " 21 "Canonical incl. wars  " 31 "Resources" 41 "Aid" 51 "Credit access" 61 "Full" , angle(45)) xtitle("Specification")   ///
					   ytitle(Coefficient) yline(0, lpattern(dash)) ///
					   legend( order(1 "Five-year benchmark" 3 "Annual estimate (times 5)")  position(3) row(6) ring(100) title("Legend", size(medsmall)))  ///
						   title("Coefficient on resource prices")
						   
						   
						   
						   graph save "Temp/Coefficient_P_ind_total_f_realshare" , replace 
						   graph export  "Output/Graphs/Appendix/APP_FIG_5_1e.pdf" , replace 
	restore 
			 
** Aid
  
  
	preserve
	
					keep if variable=="S_g5_unw_alliance_abs"

					* do not show w/o controls
				
						replace SPEC=. if SPEC==6
						replace SPEC=6 if SPEC==7

 					gen graph_position=SPEC*10+frequency_n



				label  define x     12  "Five-year benchmark"  11 "Annual estimate"     	///
									22  "Five-year benchmark"  21 "Annual estimate"   		///
									32  "Five-year benchmark"  31 "Annual estimate"  		///
									42  "Five-year benchmark"  41 "Annual estimate"  		///
									52  "Five-year benchmark"  51 "Annual estimate" 		///
									62  "Five-year benchmark"  61 "Annual estimate"  		///
									72  "Five-year benchmark"  71 "Annual estimate"  
									
							 
							 
				label  value  graph_position x 

				 rename graph_position x
							 
				
				
				twoway (scatter y1 x , msymbol(Sh) msize(medium)  xsize(8)) ///
					   (rcap yu1 yl1 x)  ///
					   (scatter y2 x , msymbol(Oh) msize(large)) ///
					   (rcap yu2 yl2 x ), scheme(lean1) ///
					   xlabel(11 "Canonical " 21 "Canonical incl. wars  " 31 "Resources" 41 "Aid" 51 "Credit access" 61 "Full"  , angle(45)) xtitle("Specification")   ///
					   ytitle(Coefficient) yline(0, lpattern(dash)) ///
					   legend( order(1 "Five-year benchmark" 3 "Annual estimate (times 5)") position(3) row(6) ring(100) title("Legend", size(medsmall)))  ///
						   title("Coefficient on aid access")
						   
						   
						   
						   graph save "Temp/Coefficient_S_g5_unw_alliance_abs" , replace 
						   graph export  "Output/Graphs/Appendix/APP_FIG_5_1f.pdf" , replace 
	restore 
			 
		
** Credit market access
  
  
	preserve
					
					replace variable="cr_market_accessXBOEinv" if variable=="cr_market_accessXIRinv"
					keep if variable=="cr_market_accessXBOEinv"
					
					* do not show w/o controls
				
						replace SPEC=. if SPEC==6
						replace SPEC=6 if SPEC==7


					gen graph_position=SPEC*10+frequency_n



				label  define x     12  "Five-year benchmark"  11 "Annual estimate"     	///
									22  "Five-year benchmark"  21 "Annual estimate"   		///
									32  "Five-year benchmark"  31 "Annual estimate"  		///
									42  "Five-year benchmark"  41 "Annual estimate"  		///
									52  "Five-year benchmark"  51 "Annual estimate" 		///
									62  "Five-year benchmark"  61 "Annual estimate"  		 
									
							 
							 
				label  value  graph_position x 

				 rename graph_position x
							 
				
				
				twoway (scatter y1 x , msymbol(Sh) msize(medium)  xsize(8)) ///
					   (rcap yu1 yl1 x)  ///
					   (scatter y2 x , msymbol(Oh) msize(large)) ///
					   (rcap yu2 yl2 x ), scheme(lean1) ///
					   xlabel(11 "Canonical " 21 "Canonical incl. wars  " 31 "Resources" 41 "Aid" 51 "Credit access" 61 "Full"   , angle(45)) xtitle("Specification")   ///
					   ytitle(Coefficient) yline(0, lpattern(dash)) ///
					   legend( order(1 "Five-year benchmark" 3 "Annual estimate (times 5)") position(3) row(6) ring(100) title("Legend", size(medsmall)))  ///
 						   title("Coefficient on credit market access")
						   
						   
						   
						   graph save "Temp/Coefficient_cr_market_accessXBOEinv" , replace 
						   graph export  "Output/Graphs/Appendix/APP_FIG_5_1g.pdf" , replace 
	restore 
	
	
	 
